﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using MyCode.Project.Infrastructure.UnityExtensions;
using System.Web.Http.Dispatcher;
using MyCode.Project.WebApi.Providers;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Utility;
using MyCode.Project.WebApi.OAuth;
using System.Web.SessionState;
using MyCode.Project.WebApi.App_Filter;
using Senparc.Weixin;
using Senparc.CO2NET;
using Senparc.CO2NET.RegisterServices;
using Senparc.Weixin.Entities;

namespace MyCode.Project.WebApi
{
    public class WebApiApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

			log4net.Config.XmlConfigurator.Configure();

            //GlobalConfiguration.Configuration.MessageHandlers.Add(new CrosHandler());

            //微信扩展缓存策略 https://www.cnblogs.com/szw/p/9265828.html
            //...

            var isGLobalDebug = false;//设置全局 Debug 状态
            var senparcSetting = SenparcSetting.BuildFromWebConfig(isGLobalDebug);
            var register = RegisterService.Start(senparcSetting).UseSenparcGlobal();//CO2NET全局注册，必须！

            var isWeixinDebug = false;//设置微信 Debug 状态
            var senparcWeixinSetting = SenparcWeixinSetting.BuildFromWebConfig(isWeixinDebug);
            register.UseSenparcWeixin(senparcWeixinSetting, senparcSetting);////微信全局注册，必须！

            //...

            Senparc.CO2NET.Config.IsDebug = isGLobalDebug;

 


            Senparc.Weixin.WeixinTrace.SendCustomLog("系统日志", "微信全局");
            Senparc.CO2NET.Trace.SenparcTrace.SendCustomLog("系统日志", "微信全局");
            register.RegisterThreads();


        }

    }
}
